package com.javasm.finance.service.impl;

import com.javasm.finance.dao.ProdDao2;
import com.javasm.finance.dao.impl.ProdDao2Impl;
import com.javasm.finance.entity.Prod;
import com.javasm.finance.entity.ProductCategory;
import com.javasm.finance.entity.User;
import com.javasm.finance.service.ProdService2;

import java.sql.SQLException;
import java.util.List;

public class ProdService2Impl implements ProdService2 {
    ProdDao2 prodDao2 =new ProdDao2Impl();

    @Override
    public List<Prod> queryProd(Integer page, Integer pageSize, String prodName, String prodCategoryName, String managerName, Integer prodState) {
        List<Prod> prodList= null;
        try {
            prodList = prodDao2.queryProd(page,pageSize,prodName,prodCategoryName,managerName,prodState);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return prodList;
    }

    @Override
    public long findTotalNum(String prodName, String prodCategoryName,String managerName, Integer prodState) {
        long totalNum = 0;
        try {
            totalNum = prodDao2.findTotalNum(prodName,prodCategoryName,managerName,prodState);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return totalNum;
    }

    @Override
    public List<ProductCategory> querySeries() {
        List<ProductCategory> list=null;
        try {
            list = prodDao2.querySeries();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }

    @Override
    public List<User> queryManager(String userName) {
        List<User> list=null;
        try {
            list = prodDao2.queryManager(userName);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }

    @Override
    public int addProd(Prod prod) {
        int rows = 0;
        try {
            rows = prodDao2.addProd(prod);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public int deleteProd(Integer prodId) {
        int rows = 0;
        try {
            rows = prodDao2.deleteProd(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public Prod findByPid(Integer prodId) {
        Prod prod = null;
        try {
            prod = prodDao2.findByPid(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return prod;
    }

    @Override
    public int editProd(Prod prod) {
        int rows = 0;
        try {
            rows = prodDao2.editProd(prod);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public Prod findByPidRemi(Integer prodId) {
        Prod prod = null;
        try {
            prod = prodDao2.findByPidRemi(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return prod;
    }

    @Override
    public int addRemi(Prod prod) {
        int rows = 0;
        try {
            rows = prodDao2.addRemi(prod);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }
}
